package org.dromara.crawler.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.crawler.domain.TargetEvent;
import org.dromara.crawler.domain.bo.ElementEventBo;
import org.dromara.crawler.domain.vo.ElementEventVo;
import org.dromara.crawler.mongo.mongodomain.ElementEvent;
import org.dromara.crawler.mongo.mongodomain.HotspotEvent;
import org.dromara.crawler.mongo.mongoservice.ElementEventService;
import org.dromara.crawler.mongo.mongoservice.HotspotEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.dev33.satoken.SaManager.log;

/**
 * 事件概览模块接口
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/elementEvent")
public class ElementEventController {

    private final ElementEventService elementEventService;

    /**
     * 事件详细信息查询
     */
    @GetMapping("/queryEventById/{id}")
    public R<ElementEvent> queryEventById(@PathVariable String id) {
        return R.ok(elementEventService.queryEventById(id));
    }

    /**
     * 事件列表查询
     */
    @GetMapping("/queryEvent")
    public R<List<ElementEventVo>> queryEvent(@RequestParam(required = false) String eventInfo) {
        return R.ok(elementEventService.queryEvent(eventInfo));
    }

    /**
     * 事件分页查询
     */
    @GetMapping("/queryByPage")
    public R<IPage<ElementEvent>> queryByPage(ElementEventBo elementEventBo, Integer pageNum, Integer pageSize) {
        return R.ok(elementEventService.queryByPage(elementEventBo, pageNum,pageSize));
    }

    /**
     * 事件空间时间线查询
     */
    @GetMapping("/getSpaceTimeLineStatistics")
    public R<Object> getSpaceTimeLineStatistics(ElementEventBo elementEventBo) {
        return R.ok(elementEventService.getSpaceTimeLineStatistics(elementEventBo));
    }

    /**
     * 事件图谱时间线查询
     */
    @GetMapping("/getGraphTimeLineStatistics")
    public R<Object> getGraphTimeLineStatistics(ElementEventBo elementEventBo) {
        return R.ok(elementEventService.getGraphTimeLineStatistics(elementEventBo));
    }

    /**
     * 根据targetID获取相关事件
     */
    @GetMapping("/queryEventList/{targetId}")
    public R<List<ElementEvent>> queryEventList(@PathVariable String targetId) {
        return R.ok(elementEventService.queryRelatedEvent(targetId));
    }

    /**
     * 事件分组
     */
    @GetMapping("/queryElementGroup")
    public R<Object> queryElementGroup(@RequestParam(required = false) String eventInfo) {
        return R.ok(elementEventService.queryEventGroup(eventInfo));
    }

}
